from __future__ import with_statement

from ZDStack.ZDSModels import Port, Weapon, GameMode, TeamColor, Map, Wad

def insert_initial_data(session):
    from ZDStack import TEAM_COLORS, SUPPORTED_GAME_MODES
    session.add(Port('zdaemon'))
    existing_colors = [x.color for x in session.query(TeamColor).all()]
    for color in [x for x in TEAM_COLORS if x not in existing_colors]:
        tc = TeamColor()
        tc.color = color
        session.add(tc)
    existing_game_modes = [gm.name for gm in session.query(GameMode).all()]
    for y in [x for x in SUPPORTED_GAME_MODES if x not in existing_game_modes]:
        session.add(GameMode(y, y in ('ctf', 'teamdm')))
    for weapon in [
        Weapon("bfg", False),
        Weapon("chaingun", False),
        Weapon("chainsaw", False),
        Weapon("death", False),
        Weapon("drowning", True),
        Weapon("exiting", True),
        Weapon("falling", True),
        Weapon("fist", False),
        Weapon("melting", True),
        Weapon("mutation", True),
        Weapon("pistol", False),
        Weapon("plasma gun", False),
        Weapon("rocket launcher", False),
        Weapon("rocket suicide", True),
        Weapon("shotgun", False),
        Weapon("suicide", True),
        Weapon("super shotgun", False),
        Weapon("teamkill", False),
        Weapon("telefrag", False)
    ]:
        session.add(weapon)
    for wad in [
        Wad('32in24-4final.wad', '32-in-24 IV', 'THIRTY4'),
        Wad('32in24-7.wad', '32-in-24 VII', 'THIRTY7'),
        Wad('madctf.wad', 'Mad CTF', 'MAD'),
        Wad('odactf1.wad', 'Odamex CTF', 'ODA'),
        Wad('zdcctfmpc.wad', 'Crazy CTF', 'CRAZY'),
        Wad('zdctfmp.wad', 'ZDaemon CTF I', 'ZDCTF'),
        Wad('zdctfmp2.wad', 'ZDaemon CTF II', 'ZDCTF'),
        Wad('zdctfmp3-.wad', 'ZDaemon CTF III', 'ZDCTF'),
        Wad('zdectfmp2.wad', 'ZDaemon Epic CTF 2', 'ZDE2'),
        Wad('zductf.wad', 'ZDaemon Ultimate CTF', 'ZDU'),
        Wad('dwango5.wad', 'DWANGO 5', 'DWANGO5'),
        Wad('dwango6.wad', 'DWANGO 6', 'DWANGO6'),
        Wad('idl2010h.wad', 'IDL 2010', 'IDL2010'),
        Wad('', '')
    ]:
        session.add(wad)
    for map in [
        Map("32in24-4final.wad", 1, "Deliverance"),
        Map("32in24-4final.wad", 2, "Cassholes"),
        Map("32in24-4final.wad", 3, "Teleflag"),
        Map(
            "32in24-4final.wad",
            4,
            "Bricks, yes bricks this time, lots of bricks (brown bricks)"
        ),
        Map("32in24-4final.wad", 5, "Knuckle Bombah"),
        Map("32in24-4final.wad", 6, "No Volition"),
        Map("32in24-4final.wad", 7, "RedvsBlue"),
        Map("32in24-4final.wad", 8, "Whoa! A Highly Advanced CTF Map"),
        Map("32in24-4final.wad", 9, "Generic Gray"),
        Map("32in24-4final.wad", 10, "Toxic"),
        Map("32in24-4final.wad", 11, "Industrial Playground"),
        Map("32in24-4final.wad", 12, "Jesus saves... AND SCORES!"),
        Map("32in24-4final.wad", 13, "Azathoth's Decayed Base of Boppin'"),
        Map("32in24-4final.wad", 14, "Nazigothitorium"),
        Map("32in24-4final.wad", 15, "Cave"),
        Map(
            "32in24-4final.wad",
            16,
            "Nyarlathotep's Evil Manse of Destruction"
        ),
        Map("32in24-4final.wad", 17, "Buntaluffigus"),
        Map("32in24-4final.wad", 18, "Skyscraper CTF"),
        Map("32in24-4final.wad", 19, "Mt. Awesome"),
        Map("32in24-4final.wad", 20, "The BIGBRIK Experience"),
        Map("32in24-4final.wad", 21, "Obligatory Power Plant"),
        Map("32in24-4final.wad", 22, "Your Clan Sucks on This Map"),
        Map("32in24-4final.wad", 23, "Wheelchair Inaccessible"),
        Map(
            "32in24-4final.wad",
            24,
            "Kass Fortress Part 2: NOT A DUEL TOWER"
        ),
        Map("32in24-4final.wad", 25, "Ernesto Attends Camp"),
        Map("32in24-4final.wad", 26, "Too Much Marble"),
        Map(
            "32in24-4final.wad",
            27,
            "Castle of Eternal Essels in the Sky"
        ),
        Map("32in24-4final.wad", 28, "Pretty Poly"),
        Map("32in24-4final.wad", 29, "Two Holds Barred"),
        Map("32in24-4final.wad", 30, "Cap Dat Shit"),
        Map("32in24-4final.wad", 31, "Mountain Zero"),
        Map("32in24-4final.wad", 32, "Kitten Factory"),
        Map("32in24-7.wad", 1, "Fear and Loathing in Dwango5"),
        Map("32in24-7.wad", 2, "Bartlett's III: The Road Warrior"),
        Map("32in24-7.wad", 3, "Velocity Kitten Go"),
        Map("32in24-7.wad", 4, "The Accursed Gorge"),
        Map("32in24-7.wad", 5, "R.I.P. Charlton Heston"),
        Map("32in24-7.wad", 6, "Bedeviled Duality"),
        Map("32in24-7.wad", 7, "City of Dirty Maniacs"),
        Map("32in24-7.wad", 8, "Really Pissed-Off Libraries"),
        Map("32in24-7.wad", 9, "Keeping It Simple"),
        Map("32in24-7.wad", 10, "The Soviet Russian Time Travel Fortress"),
        Map("32in24-7.wad", 11, "Dastardly Dick's Dizzy Discus"),
        Map("32in24-7.wad", 13, "Blood and Water"),
        Map(
            "32in24-7.wad",
            14,
            "Crazy Villagers' Ritual of Sexual Pillagers"
        ),
        Map("32in24-7.wad", 15, "Ill Descent"),
        Map("32in24-7.wad", 12, "Pyramid at Baron's Gate"),
        Map("32in24-7.wad", 16, "Oh Dear"),
        Map("32in24-7.wad", 17, "Speedy CTF"),
        Map("32in24-7.wad", 18, "FIRST WE RUSH THEN WE CRUSH"),
        Map("32in24-7.wad", 19, "Flow over Flow"),
        Map("32in24-7.wad", 20, "Tits N' Cowbell"),
        Map("32in24-7.wad", 21, "Conglom Lux"),
        Map("32in24-7.wad", 22, "Gargantuan Retarded"),
        Map("32in24-7.wad", 23, "Birth of Headache"),
        Map("32in24-7.wad", 24, "You Gotta Take the Stairs"),
        Map("32in24-7.wad", 25, "Satyun"),
        Map("32in24-7.wad", 26, "Broken Bones and Shit"),
        Map("32in24-7.wad", 27, "Insane Gunslinger Compound"),
        Map("32in24-7.wad", 28, "Dropping Loads"),
        Map("32in24-7.wad", 29, "Major League Dooming"),
        Map("32in24-7.wad", 30, "Icon of CTF"),
        Map("32in24-7.wad", 31, "Luftwaffles"),
        Map("32in24-7.wad", 32, "LOLSMALL"),
        Map("32in24-7.wad", 33, "Virgil's Leading CTF II"),
        Map("32in24-7.wad", 34, "Flushhhhh"),
        Map("32in24-7.wad", 35, "A Bad Place to Live"),
        Map("odactf1.wad", 1, "The Ride"),
        Map("odactf1.wad", 2, "Something Epic II"),
        Map("odactf1.wad", 3, "Pagan CTF"),
        Map("odactf1.wad", 4, "Zero Fort"),
        Map("odactf1.wad", 5, "Toxic Fortress"),
        Map("odactf1.wad", 6, "Lava Incorporated"),
        Map("odactf1.wad", 7, "Somewhat Complex"),
        Map("odactf1.wad", 8, "Legacy"),
        Map("zdctfmp.wad", 1, "Fortress Collision"),
        Map("zdctfmp.wad", 2, "Refineries"),
        Map("zdctfmp.wad", 3, "Exophase"),
        Map("zdctfmp.wad", 4, "Ralphis' Magical Ice Forts"),
        Map("zdctfmp.wad", 5, "Blood and Water"),
        Map("zdctfmp.wad", 6, "Cursed"),
        Map("zdctfmp.wad", 7, "The Excavation"),
        Map("zdctfmp.wad", 8, "Something Epic"),
        Map("zdctfmp.wad", 9, "Frozen"),
        Map("zdctfmp.wad", 10, "Outer Limits"),
        Map("zdctfmp2.wad", 11, "Tribute"),
        Map("zdctfmp2.wad", 12, "Subterra"),
        Map("zdctfmp2.wad", 13, "Twice as Simple"),
        Map("zdctfmp2.wad", 14, "Sanguinary Longshot"),
        Map("zdctfmp2.wad", 15, "Sewers Smell Bad"),
        Map("zdctfmp2.wad", 16, "Return to Phobos"),
        Map("zdctfmp2.wad", 17, "Burn it with Fire"),
        Map("zdctfmp2.wad", 18, "The Old Castle"),
        Map("zdctfmp2.wad", 19, "UAC Headquarters"),
        Map("zdctfmp2.wad", 20, "On the Bowl"),
        Map("zdctfmp3-.wad", 21, "On the Rocks"),
        Map("zdctfmp3-.wad", 23, "Return to Fragport"),
        Map("zdctfmp3-.wad", 22, "Mainstay"),
        Map("zdctfmp3-.wad", 24, "Crawl Space"),
        Map("zdctfmp3-.wad", 25, "Lethal Industry"),
        Map("zdctfmp3-.wad", 26, "Status: Idle"),
        Map("zdctfmp3-.wad", 27, "Exophase III"),
        Map("zdctfmp3-.wad", 28, "Rites of Passage"),
        Map("zdctfmp3-.wad", 29, "Under Siege"),
        Map("zdctfmp3-.wad", 30, "No Limits"),
        Map("zductf.wad", 1, "Tri-pod"),
        Map("zductf.wad", 2, "To the Keep"),
        Map("zductf.wad", 3, "Techno System"),
        Map("zductf.wad", 4, "For Gollum"),
        Map("zductf.wad", 5, "UAC Storage Facility"),
        Map("zductf.wad", 6, "Dust and Covers"),
        Map("zductf.wad", 7, "Sunday Afternoon"),
        Map("zductf.wad", 8, "Brickrun"),
        Map("zductf.wad", 9, "Spirit Within"),
        Map("zductf.wad", 10, "Compatible Mainframe"),
        Map("zductf.wad", 11, "Schattenland"),
        Map("zductf.wad", 12, "Danger Zone"),
        Map("zductf.wad", 13, "Romero Does"),
        Map("zductf.wad", 14, "Exophase II"),
        Map("zductf.wad", 15, "Red Hot"),
        Map("zductf.wad", 16, "The Ruins"),
        Map("zductf.wad", 17, "Castle Perimeter"),
        Map("zductf.wad", 18, "On the Line"),
        Map("zductf.wad", 19, "Underneath it All"),
        Map("zductf.wad", 20, "Floating Castle"),
        Map("zductf.wad", 21, "Tough Times"),
        Map("zductf.wad", 22, "Yami No Game"),
        Map("zductf.wad", 23, "Get to it"),
        Map("zductf.wad", 24, "Cliffhanger"),
        Map("zductf.wad", 25, "E.G.N.O.S."),
        Map("zductf.wad", 26, "Vertical Violence"),
        Map("zductf.wad", 27, "Blazing Hell"),
        Map("zductf.wad", 28, "UAC Outpost"),
        Map("zductf.wad", 29, "Very E2 Like"),
        Map("zductf.wad", 30, "Redemption II"),
        Map("zductf.wad", 31, "British Stone"),
        Map("zductf.wad", 32, "Base"),
        Map("zductf.wad", 33, "Sunday Afternoon II"),
        Map("zductf.wad", 34, "Not Kansas"),
        Map("zductf.wad", 35, "Tronish"),
        Map("zdectfmp2.wad", 1, "Cold sweats"),
        Map("zdectfmp2.wad", 2, "Zeldaemon Castle"),
        Map("zdectfmp2.wad", 3, "Pain Industry"),
        Map("zdectfmp2.wad", 4, "The Swamps"),
        Map("zdectfmp2.wad", 5, "Legacy"),
        Map("zdectfmp2.wad", 6, "The Lost Cathedrals"),
        Map("zdectfmp2.wad", 7, "Unholy War"),
        Map("zdectfmp2.wad", 8, "Souls Cemetery"),
        Map("zdectfmp2.wad", 9, "Temple of Lamentation"),
        Map("zdectfmp2.wad", 10, "The Endless Night"),
        Map("madctf.wad", 2, "Asteroid"),
        Map("madctf.wad", 3, "Open CTF"),
        Map("madctf.wad", 4, "Spaceship"),
        Map("madctf.wad", 5, "Land and Water"),
        Map("madctf.wad", 6, "Street Fighting"),
        Map("madctf.wad", 7, "Upside Down"),
        Map("madctf.wad", 8, "Upside Up"),
        Map("madctf.wad", 9, "Train"),
        Map("madctf.wad", 10, "Castles"),
        Map("madctf.wad", 11, "Caves"),
        Map("madctf.wad", 12, "UAC Refinery"),
        Map("zdcctfmpc.wad", 1, "The Chemical Imps by SpacePirate"),
        Map("zdcctfmpc.wad", 2, "Dragon Temple by Tennie"),
        Map("zdcctfmpc.wad", 3, "ES by Tennie"),
        Map("zdcctfmpc.wad", 4, "Dell by SpacePirate"),
        Map("zdcctfmpc.wad", 5, "Tering by Tennie"),
        Map("zdcctfmpc.wad", 6, "Einnet by Tennie"),
        Map("zdcctfmpc.wad", 7, "Naadster by Tennie"),
        Map("zdcctfmpc.wad", 8, "Run to the Hills by SpacePirate"),
        Map("zdcctfmpc.wad", 9, "The Last One by SpacePirate"),
        Map("zdcctfmpc.wad", 10, "Otherside? by SpacePirate"),
        Map("zdcctfmpc.wad", 11, "Naamloos by Tennie"),
        Map("zdcctfmpc.wad", 12, "Blackened Keeps by Mephisto"),
        Map("zdcctfmpc.wad", 13, "Lost by Nestea"),
        Map("zdcctfmpc.wad", 14, "No Cover by Mephisto"),
        Map("zdcctfmpc.wad", 15, "An Icy Place by Mephisto"),
        Map("zdcctfmpc.wad", 16, "Liquid by Izm"),
        Map("zdcctfmpc.wad", 17, "On the 3D Bridge by Tennie"),
        Map("zdcctfmpc.wad", 18, "Just Peachy by KillingBlair"),
        Map("zdcctfmpc.wad", 19, "Sand Gardens by Nestea"),
        Map("zdcctfmpc.wad", 20, "Hungry Hippos of Hell 2 by TUD"),
        Map("zdcctfmpc.wad", 21, "A Walk in the Base by SpacePirate"),
        Map("zdcctfmpc.wad", 22, "Broken Tiles by Tennie"),
        Map("zdcctfmpc.wad", 23, "In The Mixer by KillingBlair"),
        Map("zdcctfmpc.wad", 24, "Platina by SpacePirate"),
        Map("zdcctfmpc.wad", 25, "The Fountain by SpacePirate"),
        Map("zdcctfmpc.wad", 26, "Perfect Flag by SpacePirate"),
        Map("zdcctfmpc.wad", 27, "Lipan conjuring"),
        Map("zdcctfmpc.wad", 28, "Marine Dance by SpacePirate"),
        Map("zdcctfmpc.wad", 29, "Area666 by SpacePirate"),
        Map("zdcctfmpc.wad", 30, "Complex by Tennie"),
        Map("zdcctfmpc.wad", 31, "Grayspeed II by SpacePirate"),
        Map("zdcctfmpc.wad", 32, "Nukage War by SpacePirate"),
        Map("zdectfmp2.wad", 1, "Cold Sweats"),
        Map("zdectfmp2.wad", 11, "Battle Of Eden"),
        Map("zdectfmp2.wad", 12, "Armageddon"),
        Map("zdectfmp2.wad", 13, "Fortress Of Fighters"),
        Map("zdectfmp2.wad", 14, "2175 Equatorial"),
        Map("zdectfmp2.wad", 15, "Datadyne CTF"),
        Map("zdectfmp2.wad", 16, "Hangar n76"),
        Map("zdectfmp2.wad", 17, "Deimos Hazzard Zone"),
        Map("zdectfmp2.wad", 18, "Pain Industry II"),
        Map("zdectfmp2.wad", 19, "Toxic Refineries"),
        Map("zdectfmp2.wad", 20, "The Endless Night II"),
        Map("madctf.wad", 1, "Industrial Warfare"),
        Map("idl2010h.wad", 1, "Fortress Collision - ZDCTF01"),
        Map("idl2010h.wad", 2, "Something Epic II - ODA02"),
        Map("idl2010h.wad", 3, "Exophase - ZDCTF03"),
        Map("idl2010h.wad", 4, "R's...Magical Ice Forts - ZDCTF04"),
        Map("idl2010h.wad", 5, "Legacy - ZDECTF05"),
        Map("idl2010h.wad", 6, "Caves - MADCTF11"),
        Map("idl2010h.wad", 7, "The Excavation - ZDCTF07"),
        Map("idl2010h.wad", 8, "Something Epic - ZDCTF08"),
        Map("idl2010h.wad", 9, "Frozen - ZDCTF09"),
        Map("idl2010h.wad", 10, "The Ride - ODA01"),
        Map("idl2010h.wad", 11, "Tribute - ZDCTF11"),
        Map("idl2010h.wad", 12, "A's...Base of Boppin' - THIRTY4-13"),
        Map("idl2010h.wad", 13, "Twice As Simple - ZDCTF13"),
        Map("idl2010h.wad", 14, "Generic Gray - THIRTY4-09"),
        Map("idl2010h.wad", 15, "Sewers Smell Bad - ZDCTF15"),
        Map("idl2010h.wad", 16, "Return To Phobos - ZDCTF16"),
        Map("idl2010h.wad", 17, "Buntaluffigus - THIRTY4-17"),
        Map("idl2010h.wad", 18, "The Old Castle - ZDCTF18"),
        Map("idl2010h.wad", 19, "UAC Headquarters - ZDCTF19"),
        Map("idl2010h.wad", 20, "Cold Sweats - ZDECTF2-01"),
        Map("idl2010h.wad", 21, "An Icy Place - CRAZY15"),
        Map("idl2010h.wad", 22, "Gargantuan Retarded - THIRTY7-22"),
        Map("idl2010h.wad", 23, "Brickrun - ZDU08"),
        Map("idl2010h.wad", 24, "Crawl Space - ZDCTF24"),
        Map("idl2010h.wad", 25, "Lethal Industry - ZDCTF25"),
        Map("idl2010h.wad", 26, "Status: Idle - ZDCTF26"),
        Map("idl2010h.wad", 27, "Exophase III - ZDCTF27"),
        Map("idl2010h.wad", 28, "Unholy War - ZDECTF2-07"),
        Map("idl2010h.wad", 29, "Toxic Refineries - ZDECTF2-19"),
        Map("idl2010h.wad", 30, "Redemption II - ZDU30"),
        Map("idl2010h.wad", 31, "Mountain Zero - THIRTY4-31"),
        Map("idl2010h.wad", 32, "Insane Gunslinger Compound - THIRTY7-27"),
    ]:
        session.add(map)

